package top.cardone.data.func;

import top.cardone.context.ApplicationContextHolder;
import top.cardone.core.util.func.Func1;
import top.cardone.core.util.func.Func2;
import top.cardone.template.support.TemplateSupport;

import java.util.Map;

/**
 * @author yao hai tao
 */
public class SqlParseFunc implements Func1<String, String>, Func2<String, String, Map<String, ?>> {
    @lombok.Setter
    private String configurationKey = "configuration1";
    @lombok.Setter
    private String templateSupportBeanId = TemplateSupport.class.getName();

    @Override
    public String func(String templateString) {
        return ApplicationContextHolder.func(TemplateSupport.class, templateSupport -> templateSupport.process(configurationKey, templateString, null), templateSupportBeanId);
    }

    @Override
    public String func(String filePath, Map<String, ?> model) {
        return ApplicationContextHolder.func(TemplateSupport.class, templateSupport -> templateSupport.process(configurationKey, filePath, model), templateSupportBeanId);
    }
}
